/**
	* Copyright (c) minuteproject, minuteproject@gmail.com
	* All rights reserved.
	* 
	* Licensed under the Apache License, Version 2.0 (the "License")
	* you may not use this file except in compliance with the License.
	* You may obtain a copy of the License at
	* 
	* http://www.apache.org/licenses/LICENSE-2.0
	* 
	* Unless required by applicable law or agreed to in writing, software
	* distributed under the License is distributed on an "AS IS" BASIS,
	* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	* See the License for the specific language governing permissions and
	* limitations under the License.
	* 
	* More information on minuteproject:
	* twitter @minuteproject
	* wiki http://minuteproject.wikispaces.com 
	* blog http://minuteproject.blogspot.net
	* 
*/
/**
	* template reference : 
	* - name : OpenxavaDomainObjectUML
	* - file name : DomainObjectUMLJPAAnnotationOXAnnotationV4.vm
*/
package sistema_oficial.sistema_oficial.domain.sistemaoficial;

//MP-MANAGED-ADDED-AREA-BEGINNING @import@
//MP-MANAGED-ADDED-AREA-ENDING @import@
import java.sql.*;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;

import javax.persistence.*;
import org.openxava.annotations.*;

import calculators.*;

import sistema_oficial.sistema_oficial.domain.sistemaoficial.CobroFactura;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.ComisionVenta;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.DetalleVenta;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.OrdenSalida;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.Cliente;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.TipoFacturaVenta;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.TipoVenta;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.FormaCobroVenta;
import sistema_oficial.sistema_oficial.domain.sistemaoficial.SeccionVenta;

/**
 *
 * <p>Title: FacturaVenta</p>
 *
 * <p>Description: Domain Object describing a FacturaVenta entity</p>
 *
 */
@Entity (name="FacturaVenta")
@Table (name="factura_venta")
@Views({
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @view-base-factura_venta@
	@View(
		name="base",
		members=
        "" 	
        + "identificador  ; "
        + "fechaRegistro  ; "
        + "fechaEmision  ; "
        + "serie  ; "
        + "numero  ; "
        + "clienteCodigo  ; "
        + "tipoFacturaVentaIdentificador  ; "
        + "tipoVentaIdentificador  ; "
        + "formaCobroVentaIdentificador  ; "
        + "total  ; "
        + "base  ; "
        + "iva  ; "
        + "cobroCompleto  ; "
        + "seccionVentaCodigo  ; "
		),
//MP-MANAGED-UPDATABLE-ENDING
	@View(
		name="Create", 
		extendsView="base"
	),
	@View(
		name="Update", 
		extendsView="base",
        members=
          "" 	
	    + "cobroFactura { cobroFacturaFacturaVentaViaFacturaVentaIdentificador };" 
	    + "comisionVenta { comisionVentaFacturaVentaViaFacturaVentaIdentificador };" 
	    + "detalleVenta { detalleVentaFacturaVentaViaFacturaVentaIdentificador };" 
	    + "ordenSalida { ordenSalidaFacturaVentaViaFacturaVentaIdentificador };" 
	),
	@View(extendsView="base",
        members=
          "" 	
	    ),
    @View(name="facturaVentaDEFAULT_VIEW", 
	   members=
          " identificador ;" 	
        + "fechaRegistro  ; "
        + "fechaEmision  ; "
        + "serie  ; "
        + "numero  ; "
        + "total  ; "
        + "base  ; "
        + "iva  ; "
        + "cobroCompleto  ; "
	),
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @view-reference-factura_venta@
    @View(name="reference", 
       extendsView="facturaVentaDEFAULT_VIEW"
//MP-MANAGED-UPDATABLE-ENDING
    )
})

@Tabs({
@Tab(
properties=
     " fechaRegistro "
    +",  fechaEmision "
    +",  serie "
    +",  numero "
    +",  total "
    +",  base "
    +",  iva "
    +",  cobroCompleto "
)
,
@Tab(
name = "FacturaVentaTab",
properties=
     " fechaRegistro "
    +",  fechaEmision "
    +",  serie "
    +",  numero "
    +",  total "
    +",  base "
    +",  iva "
    +",  cobroCompleto "
)
,
@Tab(
name = "FacturaVentaTabWithRef",
properties=
     " fechaRegistro "
    +",  fechaEmision "
    +",  serie "
    +",  numero "
    +",  total "
    +",  base "
    +",  iva "
    +",  cobroCompleto "
)
})
//MP-MANAGED-ADDED-AREA-BEGINNING @class-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @class-annotation@
public class FacturaVenta {

    @Hidden @Id @Column(name="identificador" )
    private Integer identificador; 

//MP-MANAGED-ADDED-AREA-BEGINNING @fecha_registro-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @fecha_registro-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-fecha_registro@
    @Column(name="fecha_registro",   nullable=false,  unique=false)
    @Required
    private Date fechaRegistro;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @fecha_emision-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @fecha_emision-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-fecha_emision@
    @Column(name="fecha_emision",   nullable=false,  unique=false)
    @Required
    private Date fechaEmision;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @serie-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @serie-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-serie@
    @Column(name="serie",  length=25,  nullable=true,  unique=false)
    private String serie;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @numero-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @numero-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-numero@
    @Column(name="numero",  length=50, nullable=false,  unique=false)
    @Required
    private String numero;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @total-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @total-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-total@
    @Column(name="total",    nullable=true,  unique=false)
    private java.math.BigDecimal total;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @base-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @base-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-base@
    @Column(name="base",    nullable=true,  unique=false)
    private java.math.BigDecimal base;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @iva-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @iva-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-iva@
    @Column(name="iva",    nullable=true,  unique=false)
    private java.math.BigDecimal iva;	
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-ADDED-AREA-BEGINNING @cobro_completo-field-annotation@
//MP-MANAGED-ADDED-AREA-ENDING @cobro_completo-field-annotation@

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @ATTRIBUTE-cobro_completo@
    @Column(name="cobro_completo",   nullable=false,  unique=false)
    @Required
    private Boolean cobroCompleto;	
//MP-MANAGED-UPDATABLE-ENDING


//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @parent-Cliente-factura_venta@
    @ManyToOne (fetch=FetchType.LAZY ,optional=false) //remove optional=false to aggragate but leads to a side effect when going directly to the entity: required check is not performed=> if no set DB check constraint is raised...
    @JoinColumn(name="cliente_codigo", nullable=false,  unique=false  )
    @ReferenceView ("reference") 
    private Cliente clienteCodigo; 
    
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @parent-TipoFacturaVenta-factura_venta@
    @ManyToOne (fetch=FetchType.LAZY ,optional=false) //remove optional=false to aggragate but leads to a side effect when going directly to the entity: required check is not performed=> if no set DB check constraint is raised...
    @JoinColumn(name="tipo_factura_venta_identificador", nullable=false,  unique=false  )
    @ReferenceView ("reference") 
    @DefaultValueCalculator(TipoFacturaVentaCalculator.class)
    private TipoFacturaVenta tipoFacturaVentaIdentificador; 
    
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @parent-TipoVenta-factura_venta@
    @ManyToOne (fetch=FetchType.LAZY ,optional=false) //remove optional=false to aggragate but leads to a side effect when going directly to the entity: required check is not performed=> if no set DB check constraint is raised...
    @JoinColumn(name="tipo_venta_identificador", nullable=false,  unique=false  )
    @ReferenceView ("reference") 
    @DefaultValueCalculator(TipoVentaCalculator.class)
    private TipoVenta tipoVentaIdentificador; 
    
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @parent-FormaCobroVenta-factura_venta@
    @ManyToOne (fetch=FetchType.LAZY ,optional=false) //remove optional=false to aggragate but leads to a side effect when going directly to the entity: required check is not performed=> if no set DB check constraint is raised...
    @JoinColumn(name="forma_cobro_venta_identificador", nullable=false,  unique=false  )
    @ReferenceView ("reference") 
    @DefaultValueCalculator(FormaCobroVentaCalculator.class)
    private FormaCobroVenta formaCobroVentaIdentificador; 
    
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @parent-SeccionVenta-factura_venta@
    @ManyToOne (fetch=FetchType.LAZY ,optional=false) //remove optional=false to aggragate but leads to a side effect when going directly to the entity: required check is not performed=> if no set DB check constraint is raised...
    @JoinColumn(name="seccion_venta_codigo", nullable=false,  unique=false  )
    @ReferenceView ("reference") 
    private SeccionVenta seccionVentaCodigo; 
    
//MP-MANAGED-UPDATABLE-ENDING
//children
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @child-cobroFacturaFacturaVentaViaFacturaVentaIdentificador-factura_venta@
    @OneToMany (targetEntity=sistema_oficial.sistema_oficial.domain.sistemaoficial.CobroFactura.class, fetch=FetchType.LAZY, mappedBy="facturaVentaIdentificador", cascade=CascadeType.REMOVE)//, cascade=CascadeType.ALL)
    private Set <CobroFactura> cobroFacturaFacturaVentaViaFacturaVentaIdentificador = new HashSet<CobroFactura>(); 
   
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @child-comisionVentaFacturaVentaViaFacturaVentaIdentificador-factura_venta@
    @OneToMany (targetEntity=sistema_oficial.sistema_oficial.domain.sistemaoficial.ComisionVenta.class, fetch=FetchType.LAZY, mappedBy="facturaVentaIdentificador", cascade=CascadeType.REMOVE)//, cascade=CascadeType.ALL)
    private Set <ComisionVenta> comisionVentaFacturaVentaViaFacturaVentaIdentificador = new HashSet<ComisionVenta>(); 
   
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @child-detalleVentaFacturaVentaViaFacturaVentaIdentificador-factura_venta@
    @OneToMany (targetEntity=sistema_oficial.sistema_oficial.domain.sistemaoficial.DetalleVenta.class, fetch=FetchType.LAZY, mappedBy="facturaVentaIdentificador", cascade=CascadeType.REMOVE)//, cascade=CascadeType.ALL)
    private Set <DetalleVenta> detalleVentaFacturaVentaViaFacturaVentaIdentificador = new HashSet<DetalleVenta>(); 
   
//MP-MANAGED-UPDATABLE-ENDING
//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @child-ordenSalidaFacturaVentaViaFacturaVentaIdentificador-factura_venta@
    @OneToMany (targetEntity=sistema_oficial.sistema_oficial.domain.sistemaoficial.OrdenSalida.class, fetch=FetchType.LAZY, mappedBy="facturaVentaIdentificador", cascade=CascadeType.REMOVE)//, cascade=CascadeType.ALL)
    private Set <OrdenSalida> ordenSalidaFacturaVentaViaFacturaVentaIdentificador = new HashSet<OrdenSalida>(); 
   
//MP-MANAGED-UPDATABLE-ENDING
//m2m
    /**
    * Default constructor
    */
    public FacturaVenta() {
    }


    public Integer getIdentificador() {
        return identificador;
    }
	
    public void setIdentificador (Integer identificador) {
        this.identificador =  identificador;
    }
    

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-fecha_registro@
    public Date getFechaRegistro() {
        return fechaRegistro;
    }
	
    public void setFechaRegistro (Date fechaRegistro) {
        this.fechaRegistro =  fechaRegistro;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-fecha_emision@
    public Date getFechaEmision() {
        return fechaEmision;
    }
	
    public void setFechaEmision (Date fechaEmision) {
        this.fechaEmision =  fechaEmision;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-serie@
    public String getSerie() {
        return serie;
    }
	
    public void setSerie (String serie) {
        this.serie =  serie;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-numero@
    public String getNumero() {
        return numero;
    }
	
    public void setNumero (String numero) {
        this.numero =  numero;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-total@
    public java.math.BigDecimal getTotal() {
        return total;
    }
	
    public void setTotal (java.math.BigDecimal total) {
        this.total =  total;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-base@
    public java.math.BigDecimal getBase() {
        return base;
    }
	
    public void setBase (java.math.BigDecimal base) {
        this.base =  base;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-iva@
    public java.math.BigDecimal getIva() {
        return iva;
    }
	
    public void setIva (java.math.BigDecimal iva) {
        this.iva =  iva;
    } 
//MP-MANAGED-UPDATABLE-ENDING

//MP-MANAGED-UPDATABLE-BEGINNING-DISABLE @GETTER-SETTER-cobro_completo@
    public Boolean getCobroCompleto() {
        return cobroCompleto;
    }
	
    public void setCobroCompleto (Boolean cobroCompleto) {
        this.cobroCompleto =  cobroCompleto;
    } 
//MP-MANAGED-UPDATABLE-ENDING


    public Cliente getClienteCodigo () {  //
    	return clienteCodigo;
    }
	
    public void setClienteCodigo (Cliente clienteCodigo) {
    	this.clienteCodigo = clienteCodigo;//this.clienteCodigo = cliente;
    }
    public TipoFacturaVenta getTipoFacturaVentaIdentificador () {  //
    	return tipoFacturaVentaIdentificador;
    }
	
    public void setTipoFacturaVentaIdentificador (TipoFacturaVenta tipoFacturaVentaIdentificador) {
    	this.tipoFacturaVentaIdentificador = tipoFacturaVentaIdentificador;//this.tipoFacturaVentaIdentificador = tipoFacturaVenta;
    }
    public TipoVenta getTipoVentaIdentificador () {  //
    	return tipoVentaIdentificador;
    }
	
    public void setTipoVentaIdentificador (TipoVenta tipoVentaIdentificador) {
    	this.tipoVentaIdentificador = tipoVentaIdentificador;//this.tipoVentaIdentificador = tipoVenta;
    }
    public FormaCobroVenta getFormaCobroVentaIdentificador () {  //
    	return formaCobroVentaIdentificador;
    }
	
    public void setFormaCobroVentaIdentificador (FormaCobroVenta formaCobroVentaIdentificador) {
    	this.formaCobroVentaIdentificador = formaCobroVentaIdentificador;//this.formaCobroVentaIdentificador = formaCobroVenta;
    }
    public SeccionVenta getSeccionVentaCodigo () {  //
    	return seccionVentaCodigo;
    }
	
    public void setSeccionVentaCodigo (SeccionVenta seccionVentaCodigo) {
    	this.seccionVentaCodigo = seccionVentaCodigo;//this.seccionVentaCodigo = seccionVenta;
    }

    public Set<CobroFactura> getCobroFacturaFacturaVentaViaFacturaVentaIdentificador() {
        if (cobroFacturaFacturaVentaViaFacturaVentaIdentificador == null){
            cobroFacturaFacturaVentaViaFacturaVentaIdentificador = new HashSet<CobroFactura>();
        }
        return cobroFacturaFacturaVentaViaFacturaVentaIdentificador;
    }

    public void setCobroFacturaFacturaVentaViaFacturaVentaIdentificador (Set<CobroFactura> cobroFacturaFacturaVentaViaFacturaVentaIdentificador) {
        this.cobroFacturaFacturaVentaViaFacturaVentaIdentificador = cobroFacturaFacturaVentaViaFacturaVentaIdentificador;
    }	
    
    public void addCobroFacturaFacturaVentaViaFacturaVentaIdentificador (CobroFactura cobroFactura) {
    	    getCobroFacturaFacturaVentaViaFacturaVentaIdentificador().add(cobroFactura);
    }
    
    public Set<ComisionVenta> getComisionVentaFacturaVentaViaFacturaVentaIdentificador() {
        if (comisionVentaFacturaVentaViaFacturaVentaIdentificador == null){
            comisionVentaFacturaVentaViaFacturaVentaIdentificador = new HashSet<ComisionVenta>();
        }
        return comisionVentaFacturaVentaViaFacturaVentaIdentificador;
    }

    public void setComisionVentaFacturaVentaViaFacturaVentaIdentificador (Set<ComisionVenta> comisionVentaFacturaVentaViaFacturaVentaIdentificador) {
        this.comisionVentaFacturaVentaViaFacturaVentaIdentificador = comisionVentaFacturaVentaViaFacturaVentaIdentificador;
    }	
    
    public void addComisionVentaFacturaVentaViaFacturaVentaIdentificador (ComisionVenta comisionVenta) {
    	    getComisionVentaFacturaVentaViaFacturaVentaIdentificador().add(comisionVenta);
    }
    
    public Set<DetalleVenta> getDetalleVentaFacturaVentaViaFacturaVentaIdentificador() {
        if (detalleVentaFacturaVentaViaFacturaVentaIdentificador == null){
            detalleVentaFacturaVentaViaFacturaVentaIdentificador = new HashSet<DetalleVenta>();
        }
        return detalleVentaFacturaVentaViaFacturaVentaIdentificador;
    }

    public void setDetalleVentaFacturaVentaViaFacturaVentaIdentificador (Set<DetalleVenta> detalleVentaFacturaVentaViaFacturaVentaIdentificador) {
        this.detalleVentaFacturaVentaViaFacturaVentaIdentificador = detalleVentaFacturaVentaViaFacturaVentaIdentificador;
    }	
    
    public void addDetalleVentaFacturaVentaViaFacturaVentaIdentificador (DetalleVenta detalleVenta) {
    	    getDetalleVentaFacturaVentaViaFacturaVentaIdentificador().add(detalleVenta);
    }
    
    public Set<OrdenSalida> getOrdenSalidaFacturaVentaViaFacturaVentaIdentificador() {
        if (ordenSalidaFacturaVentaViaFacturaVentaIdentificador == null){
            ordenSalidaFacturaVentaViaFacturaVentaIdentificador = new HashSet<OrdenSalida>();
        }
        return ordenSalidaFacturaVentaViaFacturaVentaIdentificador;
    }

    public void setOrdenSalidaFacturaVentaViaFacturaVentaIdentificador (Set<OrdenSalida> ordenSalidaFacturaVentaViaFacturaVentaIdentificador) {
        this.ordenSalidaFacturaVentaViaFacturaVentaIdentificador = ordenSalidaFacturaVentaViaFacturaVentaIdentificador;
    }	
    
    public void addOrdenSalidaFacturaVentaViaFacturaVentaIdentificador (OrdenSalida ordenSalida) {
    	    getOrdenSalidaFacturaVentaViaFacturaVentaIdentificador().add(ordenSalida);
    }
    



//MP-MANAGED-ADDED-AREA-BEGINNING @implementation@
//MP-MANAGED-ADDED-AREA-ENDING @implementation@

}
